package com.example.evanproject.util;


import org.springframework.stereotype.Component;

import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Component
public class Getphonenum {



    public Boolean isphone(String phonenum){

        //验证手机号码格式是否正确
        String regex = "^1[3|4|5|6|7|8|9][0-9]{9}$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(phonenum);
        if (matcher.matches()) {
            System.out.println("Valid phone number");
            return true;
        } else {
            System.out.println("Invalid phone number");
            return false;
        }
    }
    /*获取验证码*///获取验证码
    public String codegenerator(){
        String captcha = UUID.randomUUID().toString()
                .replaceAll("-", "")
                .replaceAll("[a-z|A-Z]","")
                .substring(0, 6);
        String [] arr={captcha};
        return arr[0];
    }

}
